---@diagnostic disable: lowercase-global, undefined-global, trailing-space

---@class api_grogginess # 困倦/昏迷 API
local dst_lan = {}

---为角色添加grogginess组件并配置
---@param params data_grogginess[] # grogginess配置数据表
---@private
function dst_lan:AddToCharacters(params)
    for _, param in pairs(params) do
        AddPrefabPostInit(param.prefab, function(inst)
            if not TheWorld.ismastersim then
                return inst
            end
            
            -- 直接添加组件，不延迟
            if not inst.components.mod_pono_grogginess then
                inst:AddComponent("mod_pono_grogginess")
                
                -- 设置昏迷测试函数
                if param.knockout_test then
                    inst.components.mod_pono_grogginess:SetKnockOutTest(param.knockout_test)
                end
                
                -- 设置自动醒来时间
                if param.wear_off_duration then
                    inst.components.mod_pono_grogginess:SetWearOffDuration(param.wear_off_duration)
                end
                
                print("[api_grogginess] Component added to", param.prefab, "- wakeup:", param.wear_off_duration, "seconds")
            end
        end)
    end
end

---主函数
---@param params data_grogginess[] # grogginess配置数据表
function dst_lan:main(params)
    if params then
        self:AddToCharacters(params)
    end
end

return dst_lan
